function labelFormatter(e, t) {
    return "<div style='font-size:8pt; text-align:center; padding:2px; color:white;'>" + e + "<br/>" + Math.round(t.percent) + "%</div>";
}

function setCode(e) {
    $("#code").text(e.join("\n"));
}

$(function() {
    function f() {
        var e = [];
        a.find("input:checked").each(function() {
            var t = $(this).attr("name");
            t && u[t] && e.push(u[t]);
        });
        e.length > 0 && $.plot("#flotThree", e, {
            yaxis: {
                min: 0
            },
            xaxis: {
                tickDecimals: 0
            }
        });
    }
    var e = [];
    for (var t = 0; t < 14; t += .5) e.push([ t, Math.sin(t) ]);
    var n = [ [ 0, 3 ], [ 4, 8 ], [ 8, 5 ], [ 9, 13 ] ], r = [ [ 0, 12 ], [ 7, 12 ], null, [ 7, 2.5 ], [ 12, 2.5 ] ];
    $.plot("#flotOne", [ e, n, r ]);
    var e = [];
    for (var t = 0; t < 14; t += .5) e.push([ t, Math.sin(t) ]);
    var n = [ [ 0, 3 ], [ 4, 8 ], [ 8, 5 ], [ 9, 13 ] ], r = [];
    for (var t = 0; t < 14; t += .5) r.push([ t, Math.cos(t) ]);
    var i = [];
    for (var t = 0; t < 14; t += .1) i.push([ t, Math.sqrt(t * 10) ]);
    var s = [];
    for (var t = 0; t < 14; t += .5) s.push([ t, Math.sqrt(t) ]);
    var o = [];
    for (var t = 0; t < 14; t += .5 + Math.random()) o.push([ t, Math.sqrt(2 * t + Math.sin(t) + 5) ]);
    $.plot("#flotTwo", [ {
        data: e,
        lines: {
            show: !0,
            fill: !0
        }
    }, {
        data: n,
        bars: {
            show: !0
        }
    }, {
        data: r,
        points: {
            show: !0
        }
    }, {
        data: i,
        lines: {
            show: !0
        }
    }, {
        data: s,
        lines: {
            show: !0
        },
        points: {
            show: !0
        }
    }, {
        data: o,
        lines: {
            show: !0,
            steps: !0
        }
    } ]);
    var u = {
        usa: {
            label: "USA",
            data: [ [ 1988, 483994 ], [ 1989, 479060 ], [ 1990, 457648 ], [ 1991, 401949 ], [ 1992, 424705 ], [ 1993, 402375 ], [ 1994, 377867 ], [ 1995, 357382 ], [ 1996, 337946 ], [ 1997, 336185 ], [ 1998, 328611 ], [ 1999, 329421 ], [ 2e3, 342172 ], [ 2001, 344932 ], [ 2002, 387303 ], [ 2003, 440813 ], [ 2004, 480451 ], [ 2005, 504638 ], [ 2006, 528692 ] ]
        },
        russia: {
            label: "Russia",
            data: [ [ 1988, 218e3 ], [ 1989, 203e3 ], [ 1990, 171e3 ], [ 1992, 42500 ], [ 1993, 37600 ], [ 1994, 36600 ], [ 1995, 21700 ], [ 1996, 19200 ], [ 1997, 21300 ], [ 1998, 13600 ], [ 1999, 14e3 ], [ 2e3, 19100 ], [ 2001, 21300 ], [ 2002, 23600 ], [ 2003, 25100 ], [ 2004, 26100 ], [ 2005, 31100 ], [ 2006, 34700 ] ]
        },
        uk: {
            label: "UK",
            data: [ [ 1988, 62982 ], [ 1989, 62027 ], [ 1990, 60696 ], [ 1991, 62348 ], [ 1992, 58560 ], [ 1993, 56393 ], [ 1994, 54579 ], [ 1995, 50818 ], [ 1996, 50554 ], [ 1997, 48276 ], [ 1998, 47691 ], [ 1999, 47529 ], [ 2e3, 47778 ], [ 2001, 48760 ], [ 2002, 50949 ], [ 2003, 57452 ], [ 2004, 60234 ], [ 2005, 60076 ], [ 2006, 59213 ] ]
        },
        germany: {
            label: "Germany",
            data: [ [ 1988, 55627 ], [ 1989, 55475 ], [ 1990, 58464 ], [ 1991, 55134 ], [ 1992, 52436 ], [ 1993, 47139 ], [ 1994, 43962 ], [ 1995, 43238 ], [ 1996, 42395 ], [ 1997, 40854 ], [ 1998, 40993 ], [ 1999, 41822 ], [ 2e3, 41147 ], [ 2001, 40474 ], [ 2002, 40604 ], [ 2003, 40044 ], [ 2004, 38816 ], [ 2005, 38060 ], [ 2006, 36984 ] ]
        },
        denmark: {
            label: "Denmark",
            data: [ [ 1988, 3813 ], [ 1989, 3719 ], [ 1990, 3722 ], [ 1991, 3789 ], [ 1992, 3720 ], [ 1993, 3730 ], [ 1994, 3636 ], [ 1995, 3598 ], [ 1996, 3610 ], [ 1997, 3655 ], [ 1998, 3695 ], [ 1999, 3673 ], [ 2e3, 3553 ], [ 2001, 3774 ], [ 2002, 3728 ], [ 2003, 3618 ], [ 2004, 3638 ], [ 2005, 3467 ], [ 2006, 3770 ] ]
        },
        sweden: {
            label: "Sweden",
            data: [ [ 1988, 6402 ], [ 1989, 6474 ], [ 1990, 6605 ], [ 1991, 6209 ], [ 1992, 6035 ], [ 1993, 6020 ], [ 1994, 6e3 ], [ 1995, 6018 ], [ 1996, 3958 ], [ 1997, 5780 ], [ 1998, 5954 ], [ 1999, 6178 ], [ 2e3, 6411 ], [ 2001, 5993 ], [ 2002, 5833 ], [ 2003, 5791 ], [ 2004, 5450 ], [ 2005, 5521 ], [ 2006, 5271 ] ]
        },
        norway: {
            label: "Norway",
            data: [ [ 1988, 4382 ], [ 1989, 4498 ], [ 1990, 4535 ], [ 1991, 4398 ], [ 1992, 4766 ], [ 1993, 4441 ], [ 1994, 4670 ], [ 1995, 4217 ], [ 1996, 4275 ], [ 1997, 4203 ], [ 1998, 4482 ], [ 1999, 4506 ], [ 2e3, 4358 ], [ 2001, 4385 ], [ 2002, 5269 ], [ 2003, 5066 ], [ 2004, 5194 ], [ 2005, 4887 ], [ 2006, 4891 ] ]
        }
    }, t = 0;
    $.each(u, function(e, n) {
        n.color = t;
        ++t;
    });
    var a = $("#choices");
    $.each(u, function(e, t) {
        a.append("<input type='checkbox' class='choiceinput' name='" + e + "' checked='checked' id='id" + e + "'></input>" + "<label for='id" + e + "'>" + t.label + "</label>");
    });
    a.find("input").click(f);
    f();
    $(function() {
        var e = [ {
            label: "United States",
            data: [ [ 1990, 18.9 ], [ 1991, 18.7 ], [ 1992, 18.4 ], [ 1993, 19.3 ], [ 1994, 19.5 ], [ 1995, 19.3 ], [ 1996, 19.4 ], [ 1997, 20.2 ], [ 1998, 19.8 ], [ 1999, 19.9 ], [ 2e3, 20.4 ], [ 2001, 20.1 ], [ 2002, 20 ], [ 2003, 19.8 ], [ 2004, 20.4 ] ]
        }, {
            label: "Russia",
            data: [ [ 1992, 13.4 ], [ 1993, 12.2 ], [ 1994, 10.6 ], [ 1995, 10.2 ], [ 1996, 10.1 ], [ 1997, 9.7 ], [ 1998, 9.5 ], [ 1999, 9.7 ], [ 2e3, 9.9 ], [ 2001, 9.9 ], [ 2002, 9.9 ], [ 2003, 10.3 ], [ 2004, 10.5 ] ]
        }, {
            label: "United Kingdom",
            data: [ [ 1990, 10 ], [ 1991, 11.3 ], [ 1992, 9.9 ], [ 1993, 9.6 ], [ 1994, 9.5 ], [ 1995, 9.5 ], [ 1996, 9.9 ], [ 1997, 9.3 ], [ 1998, 9.2 ], [ 1999, 9.2 ], [ 2e3, 9.5 ], [ 2001, 9.6 ], [ 2002, 9.3 ], [ 2003, 9.4 ], [ 2004, 9.79 ] ]
        }, {
            label: "Germany",
            data: [ [ 1990, 12.4 ], [ 1991, 11.2 ], [ 1992, 10.8 ], [ 1993, 10.5 ], [ 1994, 10.4 ], [ 1995, 10.2 ], [ 1996, 10.5 ], [ 1997, 10.2 ], [ 1998, 10.1 ], [ 1999, 9.6 ], [ 2e3, 9.7 ], [ 2001, 10 ], [ 2002, 9.7 ], [ 2003, 9.8 ], [ 2004, 9.79 ] ]
        }, {
            label: "Denmark",
            data: [ [ 1990, 9.7 ], [ 1991, 12.1 ], [ 1992, 10.3 ], [ 1993, 11.3 ], [ 1994, 11.7 ], [ 1995, 10.6 ], [ 1996, 12.8 ], [ 1997, 10.8 ], [ 1998, 10.3 ], [ 1999, 9.4 ], [ 2e3, 8.7 ], [ 2001, 9 ], [ 2002, 8.9 ], [ 2003, 10.1 ], [ 2004, 9.8 ] ]
        }, {
            label: "Sweden",
            data: [ [ 1990, 5.8 ], [ 1991, 6 ], [ 1992, 5.9 ], [ 1993, 5.5 ], [ 1994, 5.7 ], [ 1995, 5.3 ], [ 1996, 6.1 ], [ 1997, 5.4 ], [ 1998, 5.4 ], [ 1999, 5.1 ], [ 2e3, 5.2 ], [ 2001, 5.4 ], [ 2002, 6.2 ], [ 2003, 5.9 ], [ 2004, 5.89 ] ]
        }, {
            label: "Norway",
            data: [ [ 1990, 8.3 ], [ 1991, 8.3 ], [ 1992, 7.8 ], [ 1993, 8.3 ], [ 1994, 8.4 ], [ 1995, 5.9 ], [ 1996, 6.4 ], [ 1997, 6.7 ], [ 1998, 6.9 ], [ 1999, 7.6 ], [ 2e3, 7.4 ], [ 2001, 8.1 ], [ 2002, 12.5 ], [ 2003, 9.9 ], [ 2004, 19 ] ]
        } ], t = {
            series: {
                lines: {
                    show: !0
                },
                points: {
                    show: !0
                }
            },
            legend: {
                noColumns: 2
            },
            xaxis: {
                tickDecimals: 0
            },
            yaxis: {
                min: 0
            },
            selection: {
                mode: "x"
            }
        }, n = $("#placeholder");
        n.bind("plotselected", function(i, s) {
            $("#selection").text(s.xaxis.from.toFixed(1) + " to " + s.xaxis.to.toFixed(1));
            var o = $("#zoom").attr("checked");
            o && (r = $.plot(n, e, $.extend(!0, {}, t, {
                xaxis: {
                    min: s.xaxis.from,
                    max: s.xaxis.to
                }
            })));
        });
        n.bind("plotunselected", function(e) {
            $("#selection").text("");
        });
        var r = $.plot(n, e, t);
        $("#clearSelection").click(function() {
            r.clearSelection();
        });
        $("#setSelection").click(function() {
            r.setSelection({
                xaxis: {
                    from: 1994,
                    to: 1995
                }
            });
        });
        $("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
    });
});